package com.qiang.demo01;

import java.util.ArrayList;
import java.util.LinkedList;

public class HomeWork02 {
    public static void main(String[] args) {
        /*
        2_ 测试 ArrayList和LinkedList当元素个数达到1000万的时候，

    向其中分别添加20个元素 性能分析

         */
        s1();
        s2();
    }

    private static void s1() {
        ArrayList<Integer> array = new ArrayList<>();
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000000; i++) {
            array.add(i);
        }
        for (int i = 0; i < 20; i++) {
            array.add(i);
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }
    private static void s2() {
        LinkedList<Integer> ld = new LinkedList<>();
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000000; i++) {
            ld.add(i);
        }
        for (int i = 0; i < 20; i++) {
            ld.add(i);
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }
}
